package com.tianaceae.educational.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.tianaceae.educational.mapper.EduSubjectMapper;
import com.tianaceae.educational.domain.EduSubject;
import com.tianaceae.educational.service.IEduSubjectService;

/**
 * 教务科目Service业务层处理
 * 
 * @author zhouhonggang
 * @date 2023-03-28
 */
@Service
public class EduSubjectServiceImpl implements IEduSubjectService 
{
    @Autowired
    private EduSubjectMapper eduSubjectMapper;

    /**
     * 查询教务科目
     * 
     * @param id 教务科目主键
     * @return 教务科目
     */
    @Override
    public EduSubject selectEduSubjectById(Long id)
    {
        return eduSubjectMapper.selectEduSubjectById(id);
    }

    /**
     * 查询教务科目列表
     * 
     * @param eduSubject 教务科目
     * @return 教务科目
     */
    @Override
    public List<EduSubject> selectEduSubjectList(EduSubject eduSubject)
    {
        return eduSubjectMapper.selectEduSubjectList(eduSubject);
    }

    /**
     * 新增教务科目
     * 
     * @param eduSubject 教务科目
     * @return 结果
     */
    @Override
    public int insertEduSubject(EduSubject eduSubject)
    {
        return eduSubjectMapper.insertEduSubject(eduSubject);
    }

    /**
     * 修改教务科目
     * 
     * @param eduSubject 教务科目
     * @return 结果
     */
    @Override
    public int updateEduSubject(EduSubject eduSubject)
    {
        return eduSubjectMapper.updateEduSubject(eduSubject);
    }

    /**
     * 批量删除教务科目
     * 
     * @param ids 需要删除的教务科目主键
     * @return 结果
     */
    @Override
    public int deleteEduSubjectByIds(Long[] ids)
    {
        return eduSubjectMapper.deleteEduSubjectByIds(ids);
    }

    /**
     * 删除教务科目信息
     * 
     * @param id 教务科目主键
     * @return 结果
     */
    @Override
    public int deleteEduSubjectById(Long id)
    {
        return eduSubjectMapper.deleteEduSubjectById(id);
    }

    @Override
    public int updateEduSubjectDirection(int id1, int id2, int direction) {
        int result = 0;
        if(1 == direction) {
            result += eduSubjectMapper.updateEduSubjectDirectionUp(id1);
            result += eduSubjectMapper.updateEduSubjectDirectionDown(id2);
        } else {
            result += eduSubjectMapper.updateEduSubjectDirectionDown(id1);
            result += eduSubjectMapper.updateEduSubjectDirectionUp(id2);
        }
        return result;
    }
}
